﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WISD.CarFriend.BLL.OA;
using System.Text;

namespace WISD.CarFriend.Web.Admin.OA.ParaManage
{
    public partial class ParaItemEdit : Utility.BasicPage
    {
        #region 字段
        private ParaItemModule m_ParaItemModuleBLL = new ParaItemModule();
        private int m_ParaTypeId;
        private int m_ParaItemId;
        #endregion


        #region 属性
        /// <summary>
        /// 会员卡类型编号
        /// </summary>
        public int ParaTypeId
        {
            get { return m_ParaTypeId; }
            set { m_ParaTypeId = value; }
        }
        #endregion


        #region 方法
        /// <summary>
        /// Page_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Request.QueryString["id"] == null || !int.TryParse(Request.QueryString["id"], out this.m_ParaItemId) ||
                    Request.QueryString["paraTypeId"] == null || !int.TryParse(Request.QueryString["paraTypeId"], out this.m_ParaTypeId))
                {
                    base.ShowMessageBox(350, 230, "错误提示", "<b>出现错误啦！</b>您要修改的信息不存在或参数不正确。", "back", "Error");
                    return;
                }

                if (!IsPostBack)
                {
                    // 验证权限
                    base.CheckPermission("ParaItemManage_Add");

                    WISD.CarFriend.Model.CFModel.T_CF_OA_ParaItem paraItemModel
                        = this.m_ParaItemModuleBLL.GetModel(this.m_ParaItemId);
                    if (paraItemModel != null)
                    {
                        this.txtParaItem.Text = paraItemModel.ParaItem;
                        FCKeditor.Value = paraItemModel.Memo;
                    }
                    else
                    {
                        base.ShowMessageBox(350, 230, "错误提示", "<b>出现错误啦！</b>您要修改的信息不存在或参数不正确。", "back", "Error");
                    }
                }
            }
            catch (Exception exception)
            {
                base.ShowMessageBox(350, 230, "错误提示", "<b>出现错误啦！</b>" + exception.Message.ToString(), "back", "Error");
            }
        }


        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                WISD.CarFriend.Model.CFModel.T_CF_OA_ParaItem paraItemModel
                    = this.m_ParaItemModuleBLL.GetModel(this.m_ParaItemId);
                paraItemModel.ParaItem = this.txtParaItem.Text.Trim();
                paraItemModel.Reviser = Session["UserCode"].ToString();
                paraItemModel.ReviseDate = DateTime.Now;
                paraItemModel.Memo = FCKeditor.Value.ToString().Trim();
                this.m_ParaItemModuleBLL.Update(paraItemModel);
                ShowMessageBox("修改成功！", "ParaItemList.aspx?id=" + this.m_ParaTypeId.ToString(), "Success");
            }
            catch (Exception exception)
            {
                base.ShowMessageBox(350, 230, "错误提示", "<b>出现错误啦！</b>" + exception.Message.ToString(), "back", "Error");
            }
        }
        #endregion


    }
}